#ifndef CTGlobalMacros_h
#define CTGlobalMacros_h

#define WeakSelf(weakSelf)                         __weak __typeof(&*self)weakSelf = self;
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
#ifdef DEBUG
#define NFRLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
#else
#define NFRLog(...)
#endif

#define kLineH (1 / [UIScreen mainScreen].scale)
#define kLineOffset  (kLineNeedOffset ? 0 : ((1 / [UIScreen mainScreen].scale) / 2))
#define kLineNeedOffset ((int)[UIScreen mainScreen].scale % 2 == 0)
#define UIScreenWidth                              [UIScreen mainScreen].bounds.size.width
#define UIScreenHeight                             [UIScreen mainScreen].bounds.size.height

#pragma mark - UIColor
#define UIColorFromRGBA(rgbValue, alphaValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0x0000FF))/255.0 \
alpha:alphaValue]

#define beNil(aString) (![aString isKindOfClass:[NSString class]]||[aString isKindOfClass:[NSNull class]]|| aString==nil||((NSString *)aString).length == 0||[aString stringByReplacingOccurrencesOfString:@" " withString:@""].length == 0)

#define returnBeNil(aString)\
({\
NSString *resultStr = beNil(aString) ? @"" : aString;\
(resultStr);\
})\

#define isEmpty(string) ((string) == nil || (string) == NULL || [string isKindOfClass:[NSNull class]] || [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]==0 || [(string) isEqual:@""] || [(string) isEqual:@" "])

#define kPageOfRows @"10"
#define IntToString(value) [NSString stringWithFormat:@"%ld",(long)value]

#pragma mark system version------------------
#define iOS9                         ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define kCurrentSystemVersion [[UIDevice currentDevice] systemVersion]
#define App_Version [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#pragma mark device------------------
#define kIsSimulator                    (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location)
#define kIsPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
#define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
#define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
#define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size)&& !kIsPad : NO)

#pragma mark  device------------------
#define kIS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPAD ([[[UIDevice currentDevice] model] isEqualToString:@"iPad"])
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
#define IS_SIMULATOR ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"])
#define kVersion                        [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define kIsIOS9                         ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define kFontSize(size)      [UIFont systemFontOfSize:Ratio(size)]
#define kBoldFontSize(size)      [UIFont boldSystemFontOfSize:Ratio(size)]
#define kScreenWidth        ([UIScreen mainScreen].bounds).size.width 
#define kScreenHeight       ([UIScreen mainScreen].bounds).size.height 
#define kViewSizeWidth      (self.view.frame.size.width)
#define kViewSizeHeight     (self.view.frame.size.height)
#define kLineHeight                    1.0
#define kViewControllerHeadHeight       (kStatusBarHeight+44)
#define kAutoScaleSize(size,designScreenSize)      (kScreenWidth * size / designScreenSize)

#define kIsBangsScreen ({\
    BOOL isBangsScreen = NO; \
    if (@available(iOS 11.0, *)) { \
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
    isBangsScreen = window.safeAreaInsets.bottom > 0; \
    } \
    isBangsScreen; \
})

#define kStatusBarHeight  [UIApplication sharedApplication].statusBarFrame.size.height
#define kNavBarHeight [UIViewController currentNavigationController].navigationBar.frame.size.height
#define kNavigationBarHeight (kStatusBarHeight + kNavBarHeight)
#define kSafeAreaTopHeight (kStatusBarHeight + kNavBarHeight))
#define kSafeAreaBottomHeight (kIsBangsScreen ? 34 : 0)
#define kAdaptBottomH(x) ((kStatusBarHeight > 20.0f) ? (x + 25) : x)
#define kFont(x) [UIFont systemFontOfSize:x]
#define kFontRatio(x) [UIFont systemFontOfSize:Ratio(x)]
#define Ratio(x) (int)((kScreenWidth/(kIsPad?1024:414)) * (x))
#define kCGSizeMake(x,y) CGSizeMake(Ratio(x),Ratio(y))
#define kCellLineHeight 0.5
#define SINGLE_LINE_WIDTH           (1 / [UIScreen mainScreen].scale)
#define SINGLE_LINE_ADJUST_OFFSET   ((1 / [UIScreen mainScreen].scale) / 2)
#define ViewBorderRadius(View, Radius, Width, Color)\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]
#ifndef tj_disable_animations
#define tj_disable_animations(block)\
[CATransaction begin];\
[CATransaction setDisableActions:YES];\
block();\
[CATransaction commit];
#endif
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define RGBA(r,g,b,a)               [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:a]
#define RGB(r, g, b) [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:1.0f]
#define ColorWithString(string) [UIColor colorWithString:(NSString *)string]
#define kMapDateFormat @"yyyyMMdd"     
#define kSearchRecord @"kSearchRecord"
#define kHTTask @"HTTask"

#pragma mark UserDefault

#define kUserDefaultFirstLaunch               @"kUserDefaultFirstLaunch"
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define kGetCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]
#define kloc_perssion_yes @"p5o6n7m8l9k0"
#define kloc_perssion_no @"e6r7t8y9u0o1"
#define kpage_login @"zebracharmpulse"
#define ktf_login_phoneNumber @"appleberrytwirl"
#define ktf_login_password @"bananaberrytwist"
#define kbtn_login_updatePhone @"cantaloupevortex"
#define kbtn_login_findPassword @"dragonfruitglow"
#define kbtn_login_changeUser @"elderberrybreeze"
#define kbtn_login_service @"figgrapenectar"
#define ktf_login_sms @"honeydewripple"
#define kbtn_login_unreceived @"acb_login_unreceived"
#define kct_page_creditlist_router_page @"indigoberrywave"
#define kct_page_idcard @"jackfruitvoyage"
#define kct_page_personinfo @"kiwiberrytwinkle"
#define kct_page_contact @"lemonberrybreeze"
#define kct_tf_idcard_firstname @"field_alphabravocharlie"
#define kct_tf_idcard_midname @"echofoxtrotgolfhotel"
#define kct_tf_idcard_lastname @"indiajuliettkappalima"
#define kct_btn_idcard_birthday @"hotelindiajuliettkappa"
#define kct_btn_idcard_male @"mangosteenwhirl"
#define kct_btn_idcard_female @"nectarinevortex"
#define kct_ft_idcard_bvn_number @"bravoechofoxtrotgolf"
#define kct_btn_idcard_next @"orangeberryglow"
#define kct_btn_personinfo_education @"whiskeyxrayyankeefoxtrot"
#define kct_btn_job_status @"papaqueberraromeopapa"
#define kct_btn_person_occupation @"berrycherrydance"
#define kct_btn_personinfo_monthIncome @"zulucharliedeltaechohotel"
#define kct_btn_personinfo_marriage @"indiajuliettkappalimafoxtrot"
#define kct_btn_personinfo_houseowner @"romeosierratouniformvictor"
#define kct_btn_personinfo_home_province @"yankeezuluquebcharlie"
#define kct_btn_personinfo_home_city @"deltaechofoxtrotgolfhoteljuliett"
#define kct_tf_personinfo_home_details @"mikenovemberoscarpi"
#define kct_tf_personinfo_otherphone @"queberraromeopapa"
#define kct_btn_salary_date_time @"echoflowerglow"
#define kct_btn_company_entry_time @"limamikenovemberoscar"
#define kct_tf_company_phone @"whiskeyxrayyankee"
#define kct_tf_personinfo_email @"zulucharliedeltaecho"
#define kct_btn_personinfo_next @"papayaberrytwist"
#define kct_btn_contact_firstRelation @"alphaberryblend"
#define kct_btn_contact_first_details @"quinceberrywave"
#define kct_btn_contact_spareRelation @"bravocharmflair"
#define kct_btn_contact_spare_details @"raspberrytwirl"
#define kct_btn_contact_thirdRelation @"charliedeltavibe"
#define kct_btn_contact_third_details @"strawberrybreeze"
#define kct_btn_agreement_detail @"tangerinevortex"
#define kct_btn_contact_next @"uglifruitglow"
#define kcredit_point_idcard @"foxtrotgrapemix"
#define kcredit_point_personinfo @"golfheavenly"
#define kcredit_point_contact @"indigojellytide"
#define kcredit_point_identity @"julietkaletrend"
#define kcredit_point_jobinfo @"kiwiloopenergy"
#define kpage_idcard_insertPoint @"limamelonfizz"
#define kpage_idcard_nextPoint @"mangonectarbuzz"
#define kpage_idcard_nextSucPoint @"novemberorangezest"
#define kpage_idcard_nextFailPoint @"oscarpeachglow"
#define kpage_personinfo_insertPoint @"papayapinebreeze"
#define kpage_personinfo_nextPoint @"queensanddune"
#define kpage_personinfo_nextSucPoint @"romeostrawberry"
#define kpage_personinfo_nextFailPoint @"sierratunaburst"
#define kpage_contactinfo_insertPoint @"tangoumbrellabeat"
#define kpage_contactinfo_nextPoint @"uniformvioletwave"
#define kpage_contactinfo_nextSucPoint @"victorwaterfall"
#define kpage_contactinfo_nextFailPoint @"whiskeyxanadudusk"
#define kpage_contactinfo_selfPhoneNumber @"xeroxyellowgaze"
#define kpage_contactinfo_phoneDuplicate @"yanzhefruittwist"
#define LC_auth_Success @"LC_auth_Success"      
#define LC_initialLoadFir @"LC_initialLoadFir"   
#define LC_loginSuccess @"LC_loginSuccess"        
#define LC_registrationSuccess @"LC_registrationSuccess"   
#define LC_selfRegistrationSuccess @"LC_selfRegistrationSuccess" 
#define Contact_name @"name"
#define Contact_mobile @"mobile"
#define Contact_status @"state"
#define Contact_type @"type"
#define kLcdat @"/lcdat"
#define kIsLaunchWeb @"isLaunchWeb"
#define kShowOnlineService @"showOnlineService"
#define isEncrypt @"ed=lcdcash"
#define appTelPhone @"07520507976"

#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif

#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif

#define kPreventRepeatClickTime(_seconds_) \
static BOOL shouldPrevent; \
if (shouldPrevent) return; \
shouldPrevent = YES; \
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((_seconds_) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ \
shouldPrevent = NO; \
}); \

#endif
